﻿using System;
using System.Windows;
using System.Windows.Controls;
using Shrestha.Database;

namespace Shrestha.DataWizard
{
    /// <summary>
    /// Interaction logic for SelectDb.xaml
    /// </summary>
    public partial class SelectDb : Page
    {
        private DataSourceLoader dataSourceLoader;
        public SelectDb(DataSourceLoader ds)
        {
            InitializeComponent();
            dataSourceLoader = ds;
        }

        private void buttonNext_Click(object sender, RoutedEventArgs e)
        {
            DbManager dbMan = new MySqlDbManager();
            dbMan.InitDb(textBoxHost.Text, textBoxDbName.Text, textBoxUsername.Text, textBoxPassword.Password);
            SelectTable selectTable = new SelectTable(dbMan, dataSourceLoader);
            Uri nextUri = new Uri("SelectTable.xaml", UriKind.Relative);
            this.NavigationService.Navigate(selectTable);
        }

        private void buttonCancel_Click(object sender, RoutedEventArgs e)
        {
            dataSourceLoader.DataLoaded = false;
            dataSourceLoader.Close();
        }

    }
}
